package com.web.service.impl;

import com.web.dao.MessageDao;
import com.web.entity.Message;
import com.web.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

//业务层

@Service("messageService")
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageDao messageDao;

    public void add(Message message) {
        message.setTitleTime(new Date());

        messageDao.insert(message);
    }

    public void remove(Integer id) {
        messageDao.delete(id);
    }

    public void edit(Message message) {
        messageDao.update(message);
    }

    public Message get(Integer id) {
        return messageDao.selectById(id);
    }

    public List<Message> getAll() {
        return messageDao.selectAll();
    }
}
